using System;
using Sinacor.Infra.UI.Common;
using Sinacor.Infra.UI.Security.Services;
using System.Collections.Generic;
using Sinacor.UI.Bovespa.ManutencaoOrdens.Communication.Bovespa.ManutencaoOrdens.Casamento;


namespace Sinacor.UI.Bovespa.ManutencaoOrdens.Communication {
	public class Casamento: BaseCommunication
    {

		#region Construtores 
		public Casamento(SessionInformation sessionInformation)
			: base(sessionInformation) 
		{
		} 
		#endregion Construtores

        #region Metodos
        /// <summary>
        /// CasarNegocios
        /// </summary>
        /// <param name="request"></param>
		public void CasarNegocios(Model.ChaveOrdem request, ModelCollection<Model.Negocio> requestList)
        {
            ICasamento servico = null;
            Translator.ModelToDataContract.Casamento translatorReq = new Translator.ModelToDataContract.Casamento();

            try
            {
                using (ServiceInstance<ICasamento> service = new ServiceInstance<ICasamento>())
                {
                    servico = service.TryGetInstance(this.Session);
                    servico.CasarNegocios(translatorReq.ToChaveOrdemRequest(request),
                                          translatorReq.ToNegocioRequest(requestList));
                }
            }
            catch (Exception ex)
            {
                HandleFault(ex);
            }           
		}

		/// <summary>
        /// DescasarNegocios
		/// </summary>
		/// <param name="request"></param>
		public void DescasarNegocios(ModelCollection<Model.Negocio> request)
        {
            ICasamento servico = null;

            try
            {
                using (ServiceInstance<ICasamento> service = new ServiceInstance<ICasamento>())
                {
                    servico = service.TryGetInstance(this.Session);
                    servico.DescasarNegocios(new Translator.ModelToDataContract.Casamento().ToNegocioRequest(request));
                }
            }
            catch (Exception ex)
            {
                HandleFault(ex);
            }           
		}

        /// <summary>
        /// Fgualberto.7comm
        /// </summary>
        /// <param name="parameter"></param>
        public void CasarPreBoletos(Model.Parameter.FiltroPreBoleto parameter)
        {
            ICasamento servico = null;

            try
            {
                using (ServiceInstance<ICasamento> service = new ServiceInstance<ICasamento>())
                {
                    servico = service.TryGetInstance(this.Session);
                    servico.CasarPreBoletos(new Translator.ModelToDataContract.Casamento().ToFiltroPreBoletoRequest(parameter));
                }
            }
            catch (Exception ex)
            {
                HandleFault(ex);
            }
        }
        #endregion        
	}
     
}